<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <!-- 引入vue.js  -->
    <script src="../node_modules/vue/dist/vue.js"></script>
</head>
<body>
    <!-- #app id为app的div -->
    <div id="app">
        <p>computed: "{{ showinfo }}"</p>
    </div>

    <script>
        // 实例化vuejs应用
        var vm = new Vue({
            el: "#app",
            data: {
                name: '张三',
                age: 20,
                sex: 0
            },
            computed: {
                showinfo() {
                    return `名称: ${this.name}, 年龄 ${this.age}, 性别: ${this.sex === 0 ? '男' : '女'}`
                }
            },
            mounted() {
                setTimeout(() => {
                    this.name = '李四'
                    this.age = 30
                    this.sex = 1 
                },4000)
            }
        })
    </script>
</body>
</html>